package com.inspectortime.mail.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.util.StringUtils;


import freemarker.template.Configuration;

/**
 * Represents an e-mail message that is based on a Freemarker template file
 * 
 * @author mkvalsvik
 * 
 */
public abstract class AbstractMailMessage {

	private String body;
	private Map<String, Object> data = new HashMap<String, Object>();

	private String from;
	private String replyTo;
	private String subject;
	private String to;
	public String getBody() {
		return body;
	}

	public Map getData() {
		return data;
	}

	public String getFrom() {
		return from;
	}

	public String getReplyTo() {
		return replyTo;
	}

	public String getSubject() {
		return subject;
	}
	
	public String getTo() {
		return to;
	}

	public abstract void processTemplates(Configuration freemarkerConfiguration) throws EmailDeliveryException;
	
	protected void setBody(String body) {
		this.body = body;
	}

	/**
	 * WORKAROUND: Proves a way to convert dynamic mail line breaks into HTML
	 * @return
	 */
	public abstract String getBodyHtml();

	protected void setData(Map<String, Object> data) {
		this.data = data;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public void setReplyTo(String replyTo) {
		this.replyTo = replyTo;
	}

	protected void setSubject(String subject) {
		this.subject = subject;
	}
	
	protected void setTo(String to) {
		this.to = to;
	}

}
